<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="f_userInfo">
        head<img name="user.head" src=""><input name="user.photo" type="file"><br>
        username<input name="user.username" type="text"><br>
        password<input name="user.password" type="password"><br>
        detail<textarea name="user.detail"></textarea><br>
        detail span:<span name="user.detail"></span><br>
        detail div:<div name="user.detail"></div><br>
        detail p:<p name="user.detail"></p><br>
        detail i:<i name="user.detail"></i><br>
        sex<input type="radio" name="user.sex" value="男">男<input type="radio" name="user.sex" value="女">女<br>

        hobby<input type="checkbox" name="user.hobby" value="football">football
        hobby<input type="checkbox" name="user.hobby" value="table tennis">table tennis
        <input type="checkbox" name="user.hobby" value="basketball">basketball<br>
        class<select name="user.class">
        <option value="1班">1班</option>
        <option value="2班">2班</option>
        <option value="3班">3班</option>
    </select><br>
        grade<select name="user.grade">
        <option value="1年級">1年級</option>
        <option value="2年級">2年級</option>
        <option value="3年級">3年級</option>
    </select><br>
        teacher.id<input name="user.teacher.id" type="text"><br>
        teacher.name<input name="user.teacher.name" type="text"><br>
        teacher.sex<input type="radio" name="user.teacher.sex" value="男">男<input type="radio" name="user.teacher.sex" value="女">女<br>
        age<input type="hidden" name="user.age" value="18">
        <button onclick="_getForm()">获取表单信息</button>
        <button onclick="_clearForm('#f_userInfo',false,[/user.teacher*/])">清空表单信息</button>
        <button onclick="_clearForm('#f_userInfo',true)">清空表单信息並默認選中必選</button>
        <button onclick="_init()">初始化表單</button>
        <button onclick="_last()">重現上個表單</button>
        <ul id="uu">

       </ul>
    </div>
    <div>
       
    </div>

<script src="js/jquery-3.3.1.js"></script>
<script src="js/util.js"></script>
<script>
    var model;
    function _getForm() {
        model = _getFormJson('#f_userInfo',[/user.teacher*/]);
        console.log(model)
        var formData = _getFormData('#f_userInfo',[/user.teacher*/]);
        for (var key of formData.keys()) {
            console.log("key:" + key + " value:" + formData.get(key));
        }
    }

    function _last() {
        _object2Dom('#f_userInfo',model);
    }

    function _init() {
        var m = '{"user":{"head":"images/openDoor/bg.png","username":"tom","password":"pwd","detail":"i am tom","sex":"男","hobby":"football,table tennis","class":"2班","grade":"1年級","teacher":{"id":"0","name":"zero","sex":"女"}}}';
        var mm = JSON.parse(m);
        _object2Dom('#f_userInfo',mm)
    }

    var user={name:'123',id:123456,teacher:{id:1,name:'lisi'}}
    _logInfo(_mapGetValue('name',user))
    _logInfo(_mapGetValue('id',user))
    //_logInfo(_mapGetValue('sex',user))
    _logInfo(_mapGetValue('teacher.id',user))
    _logInfo(_mapGetValue('teacher.name',user))
    //_logInfo(_mapGetValue('teacher.sex',user))

    var list = {teacher:{id:1,name:'lisi',students:[{id:1,name:'11'},{id:2,name:'22'},{id:3,name:'33'},{id:4,name:'44'},{id:5,name:'55'}]}};
    _appendDomList('#uu',list.teacher.students,function (item) {
        return '<li><input name="user.prantens" type="hidden" value="'+item.id+'">id:<span>'+item.id+'</span>name:<span>'+item.name+'</span></li>';
    })
    console.log(_getEqNameValue('#uu','user.prantens'))
    
    
    

</script>
</body>
</html>
